home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 40
/
Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso
/
Aminet
/
misc
/
emu
/
stlist.lha
/
stlist
/
stlist.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-10-20
|
2KB
|
82 lines
/* Atari .ST diskimages list */
/* Fabrizio "Lanch" Bartoloni */
/* lanch@tiscalinet.it */
/*
Thanks to: Alfonso "Alfie" Ranieri
Emiliano "Skywalk3r" Esposito
Alessandro "Crusher" Gatti
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static char verstr[] = "$VER: STList 1.2 (19.10.00)";
main(int argc, char **argv)
{
char *progname = argv[0];
char *destfile = argv[2];
FILE *fp, *fd;
char *diskimage = argv[1];
if (argc != 3)
{
fprintf(stderr, "Usage: %s diskimage.st diskcontent.txt \n", progname);
exit(1);
}
if (fp = fopen(diskimage,"rb")) {
char *buf[16]; /* filenames are 12 characters long */
/* and they fill the whole space */
/* then 4 empty + 16 trash and repeat */
/* We go to 0x0E00, here is located the beginning */
/* of the directory listing, else it must be at 0x1600 */
long offset;
int ascii;
long increase;
offset = 0x0E00L;
fseek(fp,offset,0);
ascii = fgetc(fp);
if ((ascii > 49)&&(ascii < 122))
{
offset = 0x0DE0L; /* we went one step before for the loop sake */
}
else
{
offset = 0x15E0L;
}
increase = 32L;
if (fd = fopen(destfile, "w")) {
fprintf(fd, " Listing of %s :\n\n", diskimage);
while (*buf != 0) {
offset = offset + increase;
fseek(fp,offset,0);
fgets(buf, sizeof(buf), fp);
fprintf(fd," %s\n", buf);
} /* endwhile */
fprintf(fd,"\n End of listing.\n");
exit(0);
} /* endif fopen write */
else
{
fprintf(stderr," Unable to create %s\n", destfile);
exit(1);
}
} /* endif fopen read */
else
{
fprintf(stderr, "Unable to open file: %s\n", diskimage);
exit(1);
}
fclose(fd);
fclose(fp);
return(0);
}